//
//  WHApi.m
//  WebHUD
//
//  Created by Stefan Eletzhofer on 02.12.08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import "WHApi.h"


@implementation WHApi


/**********************************************************************
 * initializer
 */
+ (id)make
{
  return [[WHApi alloc] init];
}


/**********************************************************************
 * JS API
 */
-(void)reloadMainFrame
{
  NSLog(@"WHApi reloadMainFrame, frame=%@", masterWebFrame);
  [masterWebFrame reload];
}

-(id)mainFrameDOM
{
  NSLog(@"WHApi mainFrameDOM, frame=%@", masterWebFrame);
  return [masterWebFrame DOMDocument];
}

/**********************************************************************
 * WebScripting informal Protocol
 */
+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
{

  if (aSelector == @selector(reloadMainFrame)) {
    return NO;
  }

  if (aSelector == @selector(mainFrameDOM)) {
    return NO;
  }

  return YES;
}

+ (BOOL)isKeyExcludedFromWebScript:(const char *)name
{
  //if (strcmp(name, "foo") == 0) {
  //  return NO;
  //}

  return YES;
}

- (id)invokeUndefinedMethodFromWebScript:(NSString *)name
                           withArguments:(NSArray *)args
{
  NSLog(@"WHApi invokeUndefinedMethodFromWebScript:%@ "
                                    "withArguments:%@",
                                    name, args);
  return NO;
}


/**********************************************************************
 * properties
 */
@synthesize masterWebFrame;
@synthesize masterWebView;

@end

/*vim:ts=4:sw=4:expandtab:*/
